<?php
/**
 * User: fu
 * Date: 12-3-5
 * Time: 上午12:21
 */
require 'lib/lib.php';
include 'islogin.php';

$actinfo='';
$include_src='';
$f_title='';
$head=sprintf('<script type="text/javascript" src="%s/admin/xhedit/jquery/jquery-1.4.4.min.js"></script>',SITEDIR);
$head.=sprintf('<script type="text/javascript" src="%s/admin/xhedit/xheditor-1.1.13-zh-cn.min.js"></script>',SITEDIR);
$act = isset($_GET['act']) ? $_GET['act'] : '';
$mid = isset($_GET['mid']) ? $_GET['mid'] : 0;
$curid=isset($_GET['id'])?$_GET['id']:0;
$publish = new Publish();

switch ($act) {
    case 'add':{
        if (!empty($_POST)) {
            if ($publish->add($mid, $_POST)) {
                $actinfo = Fun::echoinfo('发布成功！','succeed');
            } else {
                $actinfo = Fun::echoinfo($publish->errorinfo[2],'error');
            }

        }

        $include_src = 'publish_add.php';
        break;
    }
    case 'alt':{
        if (!empty($_POST)) {
            if ($publish->alt($mid, $_POST,$curid)) {
                $actinfo = Fun::echoinfo('修改成功！','succeed');
            } else {
                $actinfo = Fun::echoinfo($publish->errorinfo[2],'error');
            }

        }

        $include_src = 'publish_alt.php';
        break;
    }
    case 'del': {
        if (isset($_GET['confirm']) && $_GET['confirm'] === 'yes') {
            if ($publish->del($mid,$curid)) {
                $actinfo = Fun::echoinfo('删除成功！','succeed');
            } else {
                $actinfo = Fun::echoinfo($publish->errorinfo[2],'error');
            }

        }

        $include_src = 'publish_del.php';
        break;
    }
    case 'gen':{
        $generation=new Generation($publish);
        if($generation->makefile($mid)){
            $actinfo = Fun::echoinfo('生成静态文件成功！','succeed');
        }else{
            $actinfo = Fun::echoinfo($generation->errorinfo,'error');
        }

    }

    default: {
        $curpage = isset($_GET['page']) ? $_GET['page'] : 1;
        $pagesize=isset($_GET['pagesize']) ? (int)$_GET['pagesize'] : 15;;
        $publish->pagesize=$pagesize;
        $page = $publish->getpage($mid,$curpage);
        $publistharr=$publish->show($mid,$curpage);
        $include_src = 'publish_show.php';
    }
}

include ADMIN_ABS_TPL_SRC.'index.php';



